﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Century.Web.UI.MVC;
using System.Web.Mvc;
using Century.Framework.Validation;
using Century.Framework.Validation.DbProvider;

namespace Century.Admin.Controllers
{
    public class ValidationEditorController : CenturyAdminBaseController
    {

        //[HttpPost]
        public ActionResult Index(string name, string entityname, string pagename, string type, string countrySiteId)
        {
            string[] names = name.Split('.');
            name = names[names.Length - 1];
            System.Web.HttpContext.Current.Session["CurrentSiteId"] = int.Parse(countrySiteId);
            ValidationRule rule= ValidatorData.Get(Century.Business.Repository.PersistData.CurrentSiteId.ToString(), pagename, entityname, name);
            rule.TagType = type.ToLower(new System.Globalization.CultureInfo("en-US"));
            //Content : Text
            //JavaScript : Script To Run in OnSuccess Method
            //JsonResult : Json Result
            return View(rule);
        }

        [HttpPost]
        public ActionResult Save(ValidationRule validationRule)
        {
            ValidatorData.Set(validationRule);
            
            return Content("Its ok!");
        }

    }
}
